package com.yc.demo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * 1.继承
 * 2.重写
 * 3.配置
 */
@WebServlet("/getWeek.s")
public class GetWeekServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String code = req.getParameter("code");
        if (code== null){
            code="EEE";
        }

        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat(code);
        final String format = sdf.format(date);
        resp.setContentType("text/html;charSet=utf-8");
        resp.getWriter().print(format);
    }
}
